package test;

import org.mortbay.jetty.servlet.Default;
import org.tellurium.bootstrap.TelluriumSupport;
import org.tellurium.connector.SeleniumConnector;
import org.tellurium.test.java.TelluriumJavaTestCase;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import com.thoughtworks.selenium.DefaultSelenium;

import module.GoogleSearchModule;

/**
 * Test cases created based on the GoogleSearchModule UI module
 */

public class GoogleSearchTestCase extends TelluriumJavaTestCase {
	private static GoogleSearchModule gsm;

	@BeforeClass
	public static void initUi() {
		tellurium = TelluriumSupport.addSupport();
		tellurium.start(customConfig);
		connector = (SeleniumConnector) tellurium.getConnector();

		gsm = new GoogleSearchModule();
		gsm.defineUi();
	}

	@BeforeMethod
	public void connectToGoogle() {

		connectUrl("http://www.google.com");
	}

	@Test
	public void testGoogleSearchWithXPath() {
		// turn off jQuery Selector
		gsm.disableJQuerySelector();
		gsm.doGoogleSearch("tellurium Groovy Test");
	}

	@Test
	public void testGoogleSearchFeelingLuckyWithXPath() {
		// turn off jQuery Selector
		gsm.disableJQuerySelector();
		gsm.doImFeelingLucky("tellurium automated Testing");
	}

	@Test
	public void testGoogleSearchWithSelector() {
		// turn on jQuery Selector
		gsm.useJQuerySelector();
		gsm.disableSelectorCache();
		gsm.doGoogleSearch("tellurium Groovy Test");
	}

	@Test
	public void testGoogleSearchFeelingLuckyWithSelector() {
		// turn on jQuery Selector
		gsm.useJQuerySelector();
		gsm.disableSelectorCache();
		gsm.doImFeelingLucky("tellurium automated Testing");
	}

	@Test
	public void testGoogleSearchWithSelectorCached() {
		// turn on jQuery Selector
		gsm.useJQuerySelector();
		gsm.enableSelectorCache();
		gsm.setCacheMaxSize(10);
		gsm.doGoogleSearch("tellurium Groovy Test");
	}

	@Test
	public void testGoogleSearchFeelingLuckyWithSelectorCached() {
		// turn on jQuery Selector
		gsm.useJQuerySelector();
		gsm.enableSelectorCache();
		gsm.setCacheMaxSize(10);
		gsm.doImFeelingLucky("tellurium automated Testing");
	}

	@Test
	public void testDump() {
		gsm.dump("Google");
	}
}
